const mysql = require('mysql')
const sql = require('./sql.js')
const dbConfig = require('./db.js')
const express = require('express')
const bodyParser = require('body-parser')

const user = require('./api/user.js')
const car = require('./api/car.js')
const admin = require('./api/admin.js')
const upload = require('./api/upload.js')
const info = require('./api/info.js')
const notice = require('./api/notice.js')

var app = express()


app.use(bodyParser.urlencoded({
	extended: false
}))
app.use(bodyParser.json());
app.use('/upload', express.static('upload'))

app.all('*', function(req, res, next) {
	res.header("Access-Control-Allow-Origin", "*");
	res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
	res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
	res.header("X-Powered-By", ' 3.2.1')
	res.header("Content-Type", "application/json;charset=utf-8");
	next();
});

app.use('/api/user', user);
app.use('/api/car', car);
app.use('/api/admin', admin)
app.use('/api/upload', upload)
app.use('/api/info', info)
app.use('/api/notice', notice)


app.listen(3000);
console.log('success listen at port:3000......');
